#include <core/options.h>
#include <system/blockdev.h>

SimuOptsList simu_legacy_drive_opts = {
    .name = "drive",
    .head = QTAILQ_HEAD_INITIALIZER(simu_legacy_drive_opts.head),
    .desc = {
        {
            .name = "bus",
            .type = SIMU_OPT_NUMBER,
            .help = "bus number",
        },{
            .name = "unit",
            .type = SIMU_OPT_NUMBER,
            .help = "unit number (i.e. lun for scsi)",
        },{
            .name = "index",
            .type = SIMU_OPT_NUMBER,
            .help = "index number",
        },{
            .name = "media",
            .type = SIMU_OPT_STRING,
            .help = "media type (disk, cdrom)",
        },{
            .name = "if",
            .type = SIMU_OPT_STRING,
            .help = "interface (ide, scsi, sd, mtd, floppy, pflash, virtio)",
        },{
            .name = "file",
            .type = SIMU_OPT_STRING,
            .help = "file name",
        },

        /* Options that are passed on, but have special semantics with -drive */
        {
            .name = BDRV_OPT_READ_ONLY,
            .type = SIMU_OPT_BOOL,
            .help = "open drive file as read-only",
        },{
            .name = "rerror",
            .type = SIMU_OPT_STRING,
            .help = "read error action",
        },{
            .name = "werror",
            .type = SIMU_OPT_STRING,
            .help = "write error action",
        },{
            .name = "copy-on-read",
            .type = SIMU_OPT_BOOL,
            .help = "copy read data from backing file into image file",
        },

        { 0 }
    },
};

SimuOptsList simu_common_drive_opts = {
    .name = "drive",
    .head = QTAILQ_HEAD_INITIALIZER(simu_common_drive_opts.head),
    .desc = {
        {
            .name = "snapshot",
            .type = SIMU_OPT_BOOL,
            .help = "enable/disable snapshot mode",
        },{
            .name = "aio",
            .type = SIMU_OPT_STRING,
            .help = "host AIO implementation (threads, native, io_uring)",
        },{
            .name = BDRV_OPT_CACHE_WB,
            .type = SIMU_OPT_BOOL,
            .help = "Enable writeback mode",
        },{
            .name = "format",
            .type = SIMU_OPT_STRING,
            .help = "disk format (raw, qcow2, ...)",
        },{
            .name = "rerror",
            .type = SIMU_OPT_STRING,
            .help = "read error action",
        },{
            .name = "werror",
            .type = SIMU_OPT_STRING,
            .help = "write error action",
        },{
            .name = BDRV_OPT_READ_ONLY,
            .type = SIMU_OPT_BOOL,
            .help = "open drive file as read-only",
        },

        THROTTLE_OPTS,

        {
            .name = "throttling.group",
            .type = SIMU_OPT_STRING,
            .help = "name of the block throttling group",
        },{
            .name = "copy-on-read",
            .type = SIMU_OPT_BOOL,
            .help = "copy read data from backing file into image file",
        },{
            .name = "detect-zeroes",
            .type = SIMU_OPT_STRING,
            .help = "try to optimize zero writes (off, on, unmap)",
        },{
            .name = "stats-account-invalid",
            .type = SIMU_OPT_BOOL,
            .help = "whether to account for invalid I/O operations "
                    "in the statistics",
        },{
            .name = "stats-account-failed",
            .type = SIMU_OPT_BOOL,
            .help = "whether to account for failed I/O operations "
                    "in the statistics",
        },
        { NULL }
    },
};

SimuOptsList simu_drive_opts = {
    .name = "drive",
    .head = QTAILQ_HEAD_INITIALIZER(simu_drive_opts.head),
    .desc = {
        /*
         * no elements => accept any params
         * validation will happen later
         */
        {0 /* end of list */ }
    },
};
